//
//  TicketNewComCell.swift
//  ANOA
//
//  Created by 邱仙凯 on 2023/1/5.
//  Copyright © 2023 zwb. All rights reserved.
//  不敢动旧的cell，新建一个功能简单的cell来迭代

import UIKit
 
class TicketNewComCell: BaseTicketCell,UITextFieldDelegate {
   
    // 右边辅助图标
    lazy var assistBtn:UIButton = {
        let v = UIButton()
         return v
    }()
    lazy var titleLab:UILabel = {
        let v = UILabel()
        v.textColor = .lightGray
        v.font = UIFont.systemFont(ofSize: 15)
        return v
    }()
    private lazy var mustLab: UILabel = {
        var lab :UILabel = UILabel()
         lab.font = UIFont.systemFont(ofSize: 19)
        lab.textColor = .red
        lab.text = "*"
        lab.isHidden = true
        return lab
    }()
    lazy var contentLab:UITextField = {
        let v = UITextField()
        v.textColor = Theme.textColor()
        v.font = UIFont.systemFont(ofSize: 15)
        v.textAlignment = .right
        v.isUserInteractionEnabled = false
        return v
    }()
   
    func setTicketTextColor(_ color:UIColor) {
        contentLab.textColor = color
    }
    
    // 必填  内容颜色  箭头或手写笔图标 等配置
    func showStatusDeal(_ one_e:TicketModel,rowName:String) {
        
       let must = mustJudge(one_e, rowName: rowName)
        mustLab.isHidden = !must
        
       let editable = editableJudge(one_e, rowName: rowName)
        
        contentLab.textColor = editable ? Theme.textColor() : .lightGray
 
        if editable {
            if selectTypeJudge(one_e, rowName: rowName) {
                assistBtn.setBackgroundImage(UIImage(named: "formitem_right"), for: .normal)
                self.contentLab.isUserInteractionEnabled = false

            } else {
                self.contentLab.isUserInteractionEnabled = true
                assistBtn.setBackgroundImage(UIImage(named: "tenderBJ"), for: .normal)
            }

        } else {
            assistBtn.setBackgroundImage(nil, for: .normal)

        }
    }
 
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
         
        
        bg.addSubview(titleLab)
        bg.addSubview(contentLab)
        bg.addSubview(mustLab)
        bg.addSubview(assistBtn)
        titleLab.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.left.equalToSuperview().offset(12)
         }
        mustLab.snp.makeConstraints { make in
            make.centerY.equalToSuperview().offset(2)
            make.left.equalTo(titleLab.snp.right)
        }
        contentLab.snp.makeConstraints { make in
            make.top.bottom.equalToSuperview()
            make.centerY.equalToSuperview()
            make.right.equalTo(assistBtn.snp.left).offset(-5)
            make.width.greaterThanOrEqualTo(200)
        }
        assistBtn.snp.makeConstraints { make in
            make.right.equalToSuperview().offset(-3)
            make.width.equalTo(18)
            make.height.equalTo(18)
            make.centerY.equalToSuperview()
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    

}
